// @ts-ignore
/* eslint-disable */
import { PageData, PageParams } from '@/common/page';
import { request } from '@umijs/max';

export async function getRolePage(
  data: PageParams,
  options?: { [key: string]: any },
) {
  return request<{
    data: PageData;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/role/page', {
    method: 'post',
    data,
    ...(options || {}),
  });
}

export async function getRolePermission(
  params: any,
  options?: { [key: string]: any },
) {
  return request<{
    data: any;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/permission/list_by_role', {
    params,
    ...(options || {}),
  });
}

export async function addRolePermission(
  data: {
    [key: string]: any
  },
  options?: { [key: string]: any },
) {
  return request<{
    data: any;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/permission/save', {
    method: 'post',
    data,
    ...(options || {}),
  });
}

export async function updateRolePermission(
  data: {
    [key: string]: any
  },
  options?: { [key: string]: any },
) {
  return request<{
    data: Record<string, any>;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/permission/update', {
    method: 'put',
    data,
    ...(options || {}),
  });
}

export async function batchDelRolePermission(
  data: {
    [key: string]: any
  },
  options?: { [key: string]: any },
) {
  return request<{
    data: Record<string, any>;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/permission/batch_del', {
    method: 'delete',
    data,
    ...(options || {}),
  });
}

export async function updateRole(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<{
    data: Record<string, any>;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/role/update', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

export async function addRole(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<{
    data: Record<string, any>;
    msg?: string;
    code: number
    success?: boolean;
  }>('/account-service/api/permit/v1/role/add', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

export async function batchDelRole(data: { idList: any[] }, options?: { [key: string]: any }) {
  return request<{
    data: Record<string, any>;
    msg?: string;
    code: number
    success?: boolean;
  
  }>('/account-service/api/permit/v1/role/batch_del', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
